// 导入需要的config和request
import confing from '../config/config.js';
import request from '../util/request.js';
// 申明请求对象
const routeProductRequest = {
    // dict请求的基本url
    BASE_URL :  confing.PRO_URL + "/routeProduct",
    //全部分页请求
    get(page = 1,limit = 10,routeId,callback){
        // url
        let url = this.BASE_URL + "/get?page=" + page + "&limit=" + limit+ "&routeId="+routeId;
        // 发送请求
        request.get(url,callback);
    },
    //新增关联产品
    save(proRouteProduct,callback){
       let url=this.BASE_URL+'/save';
       request.post(url,proRouteProduct,callback);
    },
    deleteRouteProduct(recordId,callback){
        request.delete(this.BASE_URL+"/deleteRouteProduct?recordId="+recordId,callback);
    },
    updateRouteProduct(proRouteProduct,callback){
        let url=this.BASE_URL+'/update';
        request.post(url,proRouteProduct,callback);   
    },
    list(page = 1,limit = 10,proRouteProduct,callback){
        // url
        let url = this.BASE_URL + "/list?page=" + page + "&limit=" + limit;
        if(proRouteProduct){
            if(proRouteProduct.itemCode){
                url += "&itemCode=" +proRouteProduct.itemCode;
            }
            if(proRouteProduct.itemName){
                url += "&itemName=" +proRouteProduct.itemName;
            }
        }
        // 发送请求
        request.get(url,callback);
    },

}

// 将dictRequest暴漏出去
export default routeProductRequest;